<?php    
    $id = 0;     
    if ( !empty($_GET['id'])) {
        $id = $_REQUEST['id'];
    }
    if ( !empty($_POST)) {
        // keep track post values
        $id = $_POST['id'];
         
        // delete data
        $pdo = Database::connect();
        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $sql = "DELETE FROM posts WHERE id = ?";
        $q = $pdo->prepare($sql);
        $q->execute(array($id));
        Database::disconnect();
            echo '
                <script language>
                    $(function(){
                        alerta("Post deletado!");
                    }); 
                </script>;
            ';
            echo "<meta HTTP-EQUIV='Refresh' CONTENT='1;URL=posts'>";
         
    }
        //exibe dados sem loop
        $pdo = Database::connect();
        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $sql = "SELECT * FROM posts where id = ?";
        $q = $pdo->prepare($sql);
        $q->execute(array($id));
        $data = $q->fetch(PDO::FETCH_ASSOC);
        $nome = $data['titulo_post'];
        Database::disconnect();
?>
    <div id="page-wrapper">
        <div class="row">
          <div class="col-lg-12">
            <h1><i class="fa fa-indent"></i> <?php echo $ssposts ?></h1>                                  
          </div>
        </div><!-- /.row -->
      
        <div class="alert alert-dismissable alert-danger" style="text-align:center">
            <form class="form-horizontal" action="" method="post">
                <input type="hidden" name="id" value="<?php echo $id;?>"/>                  
                <p style="font-size:16px; color: #000">Tem certeza que deseja apagar o usuário: <b><?php echo $nome;?></b></p> 
                <p><button type="submit" class="btn btn-danger">Sim, confirmar a exclusão!</button></p>
                <p><a class="btn btn-primary" href="javascript:history.back()">Não, desejo voltar!</a></p>
            </form>
        </div>
      </div><!-- /#page-wrapper -->
    </div><!-- /#wrapper --> 